<template>
    <div>
        <page-header :title="$route.meta.title" content="由技术人员操作，其他人员请勿操作" />
        <page-main>
            <el-button type="primary" icon="el-icon-plus" @click="onCreate">新增</el-button>
            <search-bar>
                <el-form :model="form" size="small" label-width="100px" label-suffix="：">
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="名称">
                                <el-input v-model="form.modules_name" placeholder="请输入名称，支持模糊查询" clearable @keydown.enter.native="refresh" @clear="refresh" />
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-form-item>
                        <el-button type="primary" icon="el-icon-search" @click="refresh">筛 选</el-button>
                    </el-form-item>
                </el-form>
            </search-bar>
            <el-table ref="table" v-loading="loading" class="list-table" :data="listData" border stripe highlight-current-row>
                <el-table-column type="index" width="50" label="#" />
                <el-table-column prop="modules_name" width="200" label="名称" />
                <el-table-column label="权限">
                    <template slot-scope="scope">
                        <chip v-for="(item, index) in scope.row.childs" :key="index" type="success" style="margin-right: 10px;">{{ item.title }}</chip>
                    </template>
                </el-table-column>
                <el-table-column label="操作" width="200" align="center">
                    <template slot-scope="scope">
                        <el-button type="primary" size="mini" plain @click="onEdit(scope.row)">编辑</el-button>
                        <el-button type="danger" size="mini" plain @click="onDel(scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <el-pagination
                :current-page.sync="page.page"
                :total="page.total"
                :page-size.sync="page.size"
                :page-sizes.sync="page.sizes"
                layout="total, sizes, ->, prev, pager, next, jumper"
                background
                @size-change="refresh"
                @current-change="getDataList"
            />
        </page-main>
    </div>
</template>

<script>
import mixin from '@/mixins/mixin'
export default {
    mixins: [mixin],
    data() {
        return {
            dialogMode: false,
            pageRouter: {
                create: 'authAdd',
                edit: 'authEdit'
            },
            form: {
                modules_name: ''
            },
            api: {
                list: 'system/auth/tabulation',
                del: 'system/auth/delete'
            }
        }
    },
    created() {
        this.getDataList()
    },
    methods: {}
}
</script>

<style lang="scss" scoped>
    .el-pagination {
        margin-top: 20px;
    }
</style>
